#include <iostream>
#include <cctype>
#include <string>

using namespace std;

class Solution
{
public:
    int titleToNumber(string s)
    {
        int number=0;
        int a_num='a';
        for(int i=0; i<s.length(); i++)
            {
                int current_num=tolower(s[i])-a_num+1;
                number= number*26+current_num;
            }
        return number;
    }
};

int main()
{
    Solution solution;
    string s;

    while(cin>>s)
        {
            cout<<solution.titleToNumber(s)<<endl;
        }
}